var typeList = null;
var level2Menu;
var iconList;
var DEFAULT_IMG = 'images/default_m.png';
$(function(){ 
	level2Menu = new Level2Menu({				//初始化左边导航
		id:'navBox',
		moveRight:function(){			//向右事件
			iconList.setFocus();
		},
		clickType:function(data,id){		//一级菜单，没有二级是触发的函数
			$('#nav').html(data.name);
			if(data.list){
				textList.setDataList(data.dataList);
			}else{
				loadDataList(data,afterLoadDataList);
			}
		},
		clickItem:function(data,type,id){	//点击二级菜单,data,二级菜单数据,type:一级菜单数据
			$('#nav').html(type.name+'&nbsp;>&nbsp;'+data.name);
			if(data.list){
				textList.setDataList(data.dataList);
			}else{
				loadDataList(data,afterLoadDataList);
			}
		},
	});
	
	
	iconList = new IconList({			//初始化右边导航
		id:'listBox',
		moveLeft:function(){
			level2Menu.setFocus();
		},
		formatHtml:function(i,row,data){
			var img = $.getImageUrl(data.image,DEFAULT_IMG); 
			var con = '<div class="icon">';
				con += '<img src="'+img+'" />';
				con += '<a href="#" id="'+this.target+'-a-'+i+'" tar="'+i+'" row="'+row+'">&nbsp;</a>';
			con += '</div>';
			return con;
			return con;
		},
		onfocus:function(data,id){
			$.log('on focus item');
		},
		onclick:function(data,id){
			$.log($.toJSON(data));
		}
	}); 
	
	typeList = initData();
	level2Menu.setDataList(typeList,true);
	level2Menu.Click(1);
});

function afterLoadDataList(data,list){
	data.dataList = list;
	iconList.setDataList(data.dataList);
}



